<template>
  <div class="login-container">
    <div class="login-content">
      <div class="login-content-main">
        <h4 class="login-content-title ml15">
          {{ getThemeConfig.globalTitle }}
        </h4>
        <div v-if="!isScan">
          <el-tabs v-model="tabsActiveName" class="login-tabs" type="card">
            <el-tab-pane label="账号登录" name="account">
              <Account />
            </el-tab-pane>
            <el-tab-pane label="扫码登录" name="scan">
              <Scan v-if="isScan" />
            </el-tab-pane>
          </el-tabs>
        </div>
        <p class="to-register">注册账号？点击注册</p>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { toRefs, reactive, computed, defineComponent } from "vue";
import Account from "@/pages/login/component/account.vue";
import Scan from "@/pages/login/component/scan.vue";
import { useStore } from "@/store/index";

// 定义接口来定义对象的类型
interface LoginState {
  tabsActiveName: string;
  isScan: boolean;
}
definePageMeta({
  layout: "login",
});
export default defineComponent({
  name: "loginIndex",
  components: { Account, Scan },
  setup() {
    const store = useStore();
    const state = reactive<LoginState>({
      tabsActiveName: "account",
      isScan: false,
    });
    // 获取布局配置信息
    const getThemeConfig = computed(() => {
      // return { globalTitle: "天织平台" };
      console.log(store.state.themeConfig.themeConfig.globalTitle);
      return store.state.themeConfig.themeConfig;
    });
    return {
      getThemeConfig,
      ...toRefs(state),
    };
  },
});
</script>

<style scoped lang="scss">
.login-tabs {
  ::v-deep {
    .el-tabs__item {
      width: 170px;
      font-size: 16px;
      font-weight: 600;
      text-align: center;
      color: #fff;
      border: none;
    }
    .el-tabs__header {
      border: none;
    }
    .el-tabs__header .el-tabs__item.is-active {
      border: none;
      color: #41eef4;
    }
    .el-tabs__header .el-tabs__nav {
      border: none;
    }
  }
}
.login-container {
  width: 100%;
  height: 100vh;
  position: relative;
  background-image: url("@/assets/images/login_bg.png");
  background-size: 100% 100%;
  box-shadow: 0px 0px 10px 0px rgba(0, 40, 82, 0.04);
  .login-content {
    width: 50%;
    min-width: 800px;
    padding: 20px;
    position: absolute;
    right: 300px;
    top: 20%;
    box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
    background-image: url("@/assets/images/login_box.png");
    background-size: 100% 100%;
    border-radius: 5px;
    height: 560px;
    .login-content-main {
      width: 50%;
      padding: 20px 50px;
      float: right;
      .login-content-title {
        color: #fff;
        font-weight: 600;
        font-size: 26px;
        text-align: center;
        letter-spacing: 8px;
        margin: 15px 0 30px;
        white-space: nowrap;
      }
    }
    .login-content-main-sacn {
      position: absolute;
      top: 0;
      right: 0;
      width: 50px;
      height: 50px;
      overflow: hidden;
      cursor: pointer;
      transition: all ease 0.3s;
      color: var(--el-text-color-primary);
      &-delta {
        position: absolute;
        width: 35px;
        height: 70px;
        z-index: 2;
        top: 2px;
        right: 21px;
        background: var(--el-color-white);
        transform: rotate(-45deg);
      }
      &:hover {
        opacity: 1;
        transition: all ease 0.3s;
        color: var(--el-color-primary) !important;
      }
      i {
        width: 47px;
        height: 50px;
        display: inline-block;
        font-size: 48px;
        position: absolute;
        right: 2px;
        top: -1px;
      }
    }
  }
  .to-register {
    text-align: center;
    margin-top: 10px;
    color: #fff;
  }
}
</style>
